home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
STUTTGART
/
UTIL
/
SYS
/
LINEEDIT
/
!LineEdit
/
CompDoc
< prev
next >
Wrap
Text File
|
1990-10-01
|
5KB
|
126 lines
Filename Completion
-------------------
Although I don't use this feature in UN*X (I prefer the * wildcard), a few
people have requested a filename completion feature (double-ESCAPE in UNIX's
csh or ksh). Clearly, I can't use ESCAPE for this facility, so I've opted for
a SINGLE PRESS of the Tab key. This allows a filename to be filled in provided
there's a unique match with the substring already typed in.
Completion Rules are as follows :-
1) Filename matches are case insensitive, but if a partial string match is
found then the partial expansion uses the case of the first filename it
matched (plus a beep to indicate a multiple match).
2) A beep is emitted if there is no match at all.
3) The cursor can be positioned ANYWHERE along the partial filename before
Tab is pressed...in fact, anywhere along the entire pathname is acceptable
too.
4) The cursor will be positioned at the end of the filename after expansion.
5) A special parsing rule comes into effect if:
a) The entire line edit begins with a * (usually a * command) or
b) The line edit is at the Supervisor * prompt.
The problem is that abbreviated * commands do NOT require a space after
the full stop. For example, what does "*Acc.Fred" mean ? The Line Editor
can't tell whether this is (1) a "*Access Fred" or (2) an attempt to
execute a file called "Fred" inside a directory called "Acc".
To solve this, the special parsing rule will skip past the first full stop
if it is present when deciding where the filename actually starts. This
means that you can't expand case (2) above anymore, but that's going to
happen far less often than the abbreviated * command, so it's worth the
sacrifice.
If you still want to expand case (2), there are a couple of solutions:
a) Put a space after the initial * (OS_CLI skips past this).
b) Enclose the filename in double quotes.
Using the Filename Completion Routines in your own code
-------------------------------------------------------
I have designed the "Completion" source code to work as independently as
possible from the rest of the code. Despite this, programmers may still need
guidance through the routines contained inside the source:
The init_complete routine
-------------------------
On entry: No registers required.
On exit: Nothing returned, but [gbpbbuffer] points to claimed space, if any.
Action: Claims RMA space for filenames that will be returned from OS_GBPB.
Failure: If insufficient RMA, a warning will be displayed and the filename
completion routines will be disabled (they will just beep if called).
Call: Call from the module initialisation code or somewhere in your
application's startup code.
The exit_complete routine
-------------------------
On entry: No registers required, but [gbpbbuffer] points to claimed space.
On exit: Nothing returned.
Action: Frees RMA space if it was claimed by init_complete.
Failure: No errors will be returned.
Call: Call from the module finalisation code or somewhere in the
application's shutdown code.
The checkforgos routine
-----------------------
On entry: R0 = Pointer to OS_ReadLine buffer (or your own).
R1 = Maximum length of the buffer.
On exit: R1 = New maximum length of the buffer (also held in [maxlength]).
[atgosprompt] holds 1 if at a Supervisor prompt, 0 otherwise.
Action: Checks to see if supplied registers point to a Supervisor input
buffer. This is used as a special check during filename parsing
(see documentation). It also reduces the maximum buffer length
by one if it detects Gos 1.20 (fixes a bug).
Failure: No errors will be returned.
Call: Every time the address of the input buffer changes, this routine
should be called. For OS_ReadLine buffers, it should be called
upon entry to your OS_ReadLine replacement routine.
The complete_name routine
-------------------------
On entry: R0 = Pointer to OS_ReadLine buffer (or your own).
R1 = Offset of cursor on line (0 = start).
R2 = Current length of line.
On exit: No registers returned, but in the following locations instead:
[pendingright] = Number of right arrows pending buffer insertion.
[overflag] = Set to 0 to indicate a switch to Insert mode.
Keyboard buffer = Enough DELETEs (127) to erase partial filename and
add the new (partially ?) completed filename.
Action: Expands the partial filename located in the vicinity of the cursor
if possible. Because ASCII 137 (right arrow) cannot be forced into
the keyboard, the number of right arrows required is left in a
memory location to be picked up before INKEY(0) is scanned. In other
words, the insertion is 'faked' and a counter is decremented until
they are all used up, at which point normal keyboard scanning is
resumed. CHECK THE MAIN SOURCE FILE TO SEE HOW I DID THIS, YOU WILL
NEED TO IMPLEMENT SOMETHING SIMILAR.
Failure: If a unique match is not found, a beep is sounded.
Call: Set up the registers correctly and call when required (e.g. when
Tab is pressed). Will not work unless init_complete has already
been called when the module/application was initialised.